var portal = new Object("portal","#FFF","#00F",portalAction,portalDraw);

function portalAction(x,y,direction)
{
	var portals = [];
	for(i=0;i<window.game.boardWidth;++i)
	{
		for(k=0;k<window.game.boardHeight;++k)
		{
			if( window.game.table[i][k]==6 && ( (i != x) || (k != y) ))
			{
				portals[portals.length] = i+","+k ;
			}
		}
	}
	var rnd = Math.floor( Math.random()*(portals.length) );
	var portalCords = portals[rnd].split(",");
	window.game.playerX = parseInt(portalCords[0]) ;
	window.game.playerY = parseInt(portalCords[1]) ;
	return false;
}

function portalDraw(context,x,y,width,height)
{
	
}

window.game.addObject( portal );